<?php
include("jaro.php");
set_time_limit(1200);
mysql_connect("dev.ivaldi.nl", "root", "w8woord-ivaldi") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("publications") or die(mysql_error());
echo "Connected to Database<br/>";

echo '<table><tr><td>First name</td><td>Second name</td><td>JaroWinkler</td><td>Levenshtein</td></tr>';
$query = mysql_query("SELECT name FROM authors_dn");
while ($row = mysql_fetch_assoc($query)) {
	$author = $row['name'];
	$query2 = mysql_query("SELECT name FROM authors_dn");
	while ($row2 = mysql_fetch_assoc($query2)) {
		$author2 = $row2['name'];		
		$lev = levenshtein($author,$author2);
		$jarwink = JaroWinkler($author,$author2);
		//if Jaro-Winkler distance is greater dan 0.9, but not equal, print result
		if($jarwink > 0.9 && $jarwink != 1){
			echo '<tr><td>'.$author.'</td><td>'.$author2.'</td><td>'.$jarwink.'</td><td>'.$lev.'</td></tr>';		
			break;
		}
	}
}
echo '</table>';
?>
